package com.qwt.part_time_api.service.impl;

import com.qwt.part_time_api.mapper.NumberMapper;
import com.qwt.part_time_api.pojo.Number;
import com.qwt.part_time_api.service.NumberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author 君子慎独
 * @create 2022/1/22 0022 23:05
 */
@Slf4j
@Service
public class NumberServiceImpl implements NumberService {

    @Autowired
    private NumberMapper numberMapper;

    @Override
    public int findMax() {
        log.info("获取编号");
        Number number = numberMapper.selectById(1);
        return number.getMax();
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void updateMax(int max) {
        log.info("更新编号");
        Number number = new Number();
        number.setId(1L);
        number.setMax(max);
        numberMapper.updateById(number);
    }
}
